import 'package:flutter/material.dart';
import 'package:myapp/test_page/new_route.dart';
import 'package:myapp/test_page/new_route_align.dart';
import 'package:myapp/test_page/new_route_btn_test.dart' as btn_test;
import 'package:myapp/test_page/new_route_container.dart';
import 'package:myapp/test_page/new_route_customer_view.dart';
import 'package:myapp/test_page/new_route_dialog.dart';
import 'package:myapp/test_page/new_route_dio.dart';
import 'package:myapp/test_page/new_route_event_point.dart';
import 'package:myapp/test_page/new_route_flex.dart';
import 'package:myapp/test_page/new_route_flow.dart';
import 'package:myapp/test_page/new_route_future.dart';
import 'package:myapp/test_page/new_route_gridview.dart';
import 'package:myapp/test_page/new_route_img_icon.dart' as img_test;
import 'package:myapp/test_page/new_route_checkbox_test.dart' as check_box_test;
import 'package:myapp/test_page/new_route_list_view.dart';
import 'package:myapp/test_page/new_route_list_view_2.dart';
import 'package:myapp/test_page/new_route_list_view_4.dart';
import 'package:myapp/test_page/new_route_list_view_interval.dart';
import 'package:myapp/test_page/new_route_one3.dart';
import 'package:myapp/test_page/new_route_paint.dart';
import 'package:myapp/test_page/new_route_popscore.dart';
import 'package:myapp/test_page/new_route_process.dart';
import 'package:myapp/test_page/new_route_row_col.dart';
import 'package:myapp/test_page/new_route_row_col_2.dart';
import 'package:myapp/test_page/new_route_scroll_1.dart';
import 'package:myapp/test_page/new_route_stack_position.dart';
import 'package:myapp/test_page/new_route_stream.dart';
import 'package:myapp/test_page/new_route_textfield.dart';
import 'package:myapp/test_page/new_route_wrap.dart';
import 'package:myapp/test_page/route_test.dart';
import 'package:myapp/test_page/start_page.dart';

class MyAppTestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'my app',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'my app'),
      routes: {
        "start_page": (BuildContext context) => NewRoute(),
        "start_page2": (BuildContext context) => startPage(),
        "start_page3": (BuildContext context) => RouterTestRoute(),
        "tip2": (context) => TipRoute(text: ModalRoute.of(context).settings.arguments),
        "new_btn_test": (BuildContext context) => btn_test.NewRoute(),
        "new_img_test": (BuildContext context) => img_test.NewRoute(),
        "new_check_box_test": (BuildContext context) => check_box_test.NewRoute(),
        "new_check_text_field": (BuildContext context) => NewRouteTextField(),
        "new_check_progress": (BuildContext context) => NewRouteProgress(),
        "new_row_col": (BuildContext context) => NewRouteRowCol(),
        "new_row_col_2": (BuildContext context) => NewRouteRowCol2(),
      },
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Wrap(
          spacing: 4.0, // 主轴(水平)方向间距
          runSpacing: 4.0, // 纵轴（垂直）方向间距
          alignment: WrapAlignment.center, //沿主轴方向居中
          children: <Widget>[
            TestButton2("NewRouteDio",NewRouteDio()),
            TestButton2("NewRoutePaint",NewRoutePaint()),
            TestButton2("NewRouteEventPoint",NewRouteEventPoint()),
            TestButton2("NewRouteDialog",NewRouteDialog()),
            TestButton2("NewRouteStream",NewRouteStream()),
            TestButton2("NewRouteFuture",NewRouteFuture()),
            TestButton2("NewRouteWillPop",NewRouteWillPop()),
            TestButton2("NewRouteCustomerScroll",NewRouteCustomerScroll()),
            TestButton2("grid view2",NewRouteGridView2()),
            TestButton2("grid view",NewRouteGridView()),
            TestButton2("list view interval 4",NewRouteListView4()),
            TestButton2("list view interval",NewRouteListViewInterval()),
            TestButton2("list view2",NewRouteListView2()),
            TestButton2("list view",NewRouteListView()),
            TestButton2("scroll",NewRouteScroll()),
            TestButton2("container",NewRouteContainer()),
            TestButton2("align",NewRouteAlign()),
            TestButton2("stack position",NewRouteStackPosition()),
            TestButton2("flow",NewRouteFlow()),
            TestButton2("wrap",NewRouteWrap()),
            TestButton2("Flex",NewRouteFlex()),
            TestButton("图片测试", "start_page"),
            TestButton("跳转测试", "start_page"),
            TestButton("跳转带返回值测试", "start_page3"),
            TestButton("跳转带返回值测试2", "start_page", args: "hi named"),
            TestButton("跳转带返回值测试3", "start_page2", args: "hi named2"),
            TestButton("按钮测试", "new_btn_test"),
            TestButton("图片测试", "new_img_test"),
            TestButton("控件测试测试", "new_check_box_test"),
            TestButton("表单测试", "new_check_text_field"),
            TestButton("进度条测试", "new_check_progress"),
            TestButton("行列测试", "new_row_col"),
            TestButton("行列测试2", "new_row_col_2"),
            TestButton2("行列测试3",NewRouteRowCol3()),
          ],
        ),
      ),
    );
  }
}

class TestButton extends StatelessWidget {
  TestButton(this.text, this.to, {this.args});

  String to;
  String text;
  Object args;

  @override
  Widget build(BuildContext context) {
    return FlatButton(
      color: Colors.black12,
      child: Text(text),
      onPressed: () {
        Navigator.pushNamed(context, to);
      },
    );
  }
}

class TestButton2 extends StatelessWidget {
  TestButton2(this.text, this.to, {this.args});

  Widget to;
  String text;
  Object args;

  @override
  Widget build(BuildContext context) {
    return FlatButton(
      color: Colors.black12,
      child: Text(text),
      onPressed: () {
        Navigator.push(context, MaterialPageRoute(builder: (context) {
          return to;
        }));
      },
    );
  }
}
